-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Add a new lint UNCONSTRUCTABLE_PUB_STRUCT to detect unconstructable public structs
#146440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add a new lint UNCONSTRUCTABLE_PUB_STRUCT to detect unconstructable public structs
#146440
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
UNCONSTRUCTIBLE_PUB_STRUCT to detect unconstructible public structs
|
Would the lint fire on token structs that are public, have private fields, have no public constructor method, but expose a limited number of pre-constructed objects, e.g. through a static that contains an optional token? |
won't fire like private types used in such places |
480b1d7 to
021712b
Compare
|
Nominating for t-lang to decide whether we want this lint, then I'll review the implementation. Also, s/unconstructible/unconstructable. |
UNCONSTRUCTIBLE_PUB_STRUCT to detect unconstructible public structsUNCONSTRUCTABLE_PUB_STRUCT to detect unconstructable public structs
This comment was marked as resolved.
This comment was marked as resolved.
6075d81 to
497ad71
Compare
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
497ad71 to
b3b3a05
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Does this trigger on structs that are intended only as marker types in generic parameters? |
Such types usually have intended private unit fields and this won't trigger on them. This will only trigger types with trivial fields but not be used or cannot be constructed. |
Add a new lint UNCONSTRUCTABLE_PUB_STRUCT to detect unconstructable public structs, based on the following observations: